package com.dios.mirage.screen;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

import com.dios.mirage.Mirage;
import com.dios.mirage.component.HeaderManager;
import com.dios.mirage.content.HomeContent;
import com.dios.mirage.interfaces.ScreenInterface;

public class FirstScreen extends MainScreen implements ScreenInterface{
	
	protected VerticalFieldManager layoutManager = new VerticalFieldManager();
	protected VerticalFieldManager contentManager = new VerticalFieldManager(Manager.VERTICAL_SCROLLBAR);

	public FirstScreen(String title) {
		super();
		setTitle(Mirage.TITLE + title);
		createGUI();
	}

	public void createGUI() {
		HeaderManager headerManager = new HeaderManager();
		layoutManager.add(headerManager);
		contentManager.add(new HomeContent());
		add(layoutManager);
		add(contentManager);
	}	
	
	protected void sublayout(int arg0, int arg1) {
		super.sublayout(arg0, arg1);
		
	}

	public void setContent(Field field){
		contentManager.deleteAll();
		if(field != null)contentManager.add(field);
	}
	
	public void setTtl(String title){
		setTitle(Mirage.TITLE + title);
	}
	
	public boolean onClose() {
        int choice = Dialog.ask(Dialog.D_YES_NO, "Do you want to exit?", Dialog.YES);
        if (choice == Dialog.YES) {
            System.exit(1);
        }   
        return true;
    }
}
